﻿using MediatR;
using SystemMHB.API.Application.Command.WarehouseCommand;
using SystemMHB.Infrstructer.Interface;

namespace SystemMHB.API.Application.CommandHandlers.WarehouseCommandHandler
{
    public class WarehouseUpdateCommandHandler : IRequestHandler<WarehouseUpdateCommand, int>
    {
        /// <summary>
        /// 仓库管理仓储
        /// </summary>
        IWarehouseRepository WarRep;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="WarRep">仓库管理仓储</param>
        public WarehouseUpdateCommandHandler(IWarehouseRepository WarRep)
        {
            this.WarRep = WarRep;
        }

        public async Task<int> Handle(WarehouseUpdateCommand request, CancellationToken cancellationToken)
        {
            request.UpdateName = "张三";
            request.UpdateTime = DateTime.Now.ToUniversalTime();
            return await WarRep.UpdateAsync(new Domian.Warehouse()
            {
                warehouseID = request.warehouseID,
                warehouseNumber = request.warehouseNumber,
                warehouseName = request.warehouseName,
                warehouseArea = request.warehouseArea,
                selectWarehouseArea = request.selectWarehouseArea,
                positionNumber = request.positionNumber,
                principal = request.principal,
                warehouseState = request.warehouseState,
                warehouseRemark = request.warehouseRemark,
                IsDel = request.IsDel,
                AddName = request.AddName,
                AddTime = request.AddTime,
                UpdateName= request.UpdateName,
                UpdateTime = request.UpdateTime,
            });
        }
    }
}
